/*
 * @Author: yangzonglong
 * @Date: 2021-03-01 13:18:46
 * @version: v1.0.0
 * @Descripttion:
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-08-17 10:35:27
 * @Auditor:
 */
import React, { useMemo } from 'react';
import { Input } from 'antd';

const App = (props: any) => {

  const { columns, onChange, _dataIndex, value, _columns } = props;

  const _options = useMemo(() => {
    if (Array.isArray(columns) && _dataIndex) {
      const _item = columns.filter(item => item.dataIndex === _dataIndex);
      return _item?.[0] || { options: {} };
    } else {
      return { options: {} };
    }

  }, [columns, _dataIndex]);

  const placeholder = localStorage.i18nextLng === 'en' ? _options?.options?.placeholderEn : _options?.options?.placeholder;

  return <Input size='small' placeholder={placeholder} disabled={
    (_options.disabled === undefined ? _options.options.bindName : _options.disabled)
  } value={value} onChange={onChange} style={{ textAlign: _columns.textAlign || 'left' }} />;
};

export default App;
